package com.example.demo.common.utils.demo;

import com.example.demo.common.utils.BaseResponse;
import com.example.demo.common.utils.HttpUtil;
import com.example.demo.common.utils.RSAHelper;
import com.example.demo.common.utils.demo.common.Config;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by zhangws on 2019/9/29 14:08.
 */
public class CompanyInfo {
    static Logger log = LoggerFactory.getLogger(CompanyInfo.class);
    /**
     * 查询公司发票信息以及主体信息*
     */
    public static void queryInvoicesAndMainstay(){

        String url = Config.baseUrl+"/open/api/v1/company/queryInvoices";
        String paramsJson = "";//该接口无许参数直接为 "" 即可
        BaseResponse baseResponse = HttpUtil.post(url,paramsJson,Config.appKey,Config.secretkey,Config.publicKey);
        if (baseResponse.isSuccess()){
            String rs = baseResponse.getData().toString();
            //公钥解密
            if (StringUtils.isNotBlank(rs)){
                try {
                    String dec = RSAHelper.decryptByPublicKey(rs,Config.publicKey);
                    log.info(String.format("解密结果:%s",dec));
                }catch (Exception e){
                    log.info("publicKey 有误");
                }
            }
        }
    }
}
